{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## elif statement"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Must be after an if statement. elif statement statement allows you to check multiple expressions for True and execute a block of code as soon as one of the conditions evaluates to True.\n",
    "\n",
    "Similar to the else, the elif statement is optional. However, unlike else, for which there can be at most one statement, there can be an arbitrary number of elif statements following an if."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 70,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "num = 21\n"
     ]
    }
   ],
   "source": [
    "num = 21\n",
    "if num > 50:\n",
    "    print('num is larger than 50')\n",
    "elif num == 21:\n",
    "    print('num = 21')\n",
    "else:\n",
    "    print('Catchall condition')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 71,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Your number is odd\n"
     ]
    }
   ],
   "source": [
    "my_num = 5\n",
    "if my_num % 2 == 0:\n",
    "    print(\"Your number is even\")\n",
    "elif my_num % 2 != 0:\n",
    "    print(\"Your number is odd\")\n",
    "else: \n",
    "    print(\"Are you sure your number is an integer?\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Later on in the tutorial series, we will go over simulating dice rolls and talking about the distribution"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 72,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "You rolled a 1. Great job!\n"
     ]
    }
   ],
   "source": [
    "# You can have mulitple elif statements. \n",
    "# Remember only the first True statement has its block of code executed. \n",
    "\n",
    "dice_value = 1\n",
    "if dice_value == 1:\n",
    "    print('You rolled a {}. Great job!'.format(dice_value))\n",
    "elif dice_value == 2:\n",
    "    print('You rolled a {}. Great job!'.format(dice_value))\n",
    "elif dice_value == 3:\n",
    "    print('You rolled a {}. Great job!'.format(dice_value))\n",
    "elif dice_value == 4:\n",
    "    print('You rolled a {}. Great job!'.format(dice_value))\n",
    "elif dice_value == 5:\n",
    "    print('You rolled a {}. Great job!'.format(dice_value))\n",
    "elif dice_value == 6:\n",
    "    print('You rolled a {}. Great job!'.format(dice_value))\n",
    "else:\n",
    "    print('None of the conditions above (if elif) were evaluated as True')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<b>Task</b>"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "1. Assign num to an integer value. \n",
    "2. Write a series of if, elif, else statements that will print the num you assigned. But for multiples of three print \"Fizz\" instead of the number and for the multiples of five print \"Buzz\". For numbers which are multiples of both three and five print \"FizzBuzz\"."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 73,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "# Solution 1\n",
    "num = 10"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 74,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Buzz\n"
     ]
    }
   ],
   "source": [
    "if num % 3 == 0 and num % 5 == 0:\n",
    "    print('FizzBuzz')\n",
    "elif num % 3 == 0:\n",
    "    print('Fizz')\n",
    "elif num % 5 == 0:\n",
    "    print('Buzz')\n",
    "else:\n",
    "    print(str(num))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 75,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "# Solution 2\n",
    "num = 15"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 76,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "FizzBuzz\n"
     ]
    }
   ],
   "source": [
    "\"\"\"Notice how difficult this solution is relative to Solution 1\"\"\"\n",
    "\n",
    "string = \"\"\n",
    "if num % 3 == 0:\n",
    "    string = string + \"Fizz\"\n",
    "if num % 5 == 0:\n",
    "    string = string + \"Buzz\"\n",
    "if num % 5 != 0 and num % 3 != 0:\n",
    "    string = string + str(num)\n",
    "print(string)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "**if this tutorial doesn't cover what you are looking for, please leave a comment on the youtube video and I will try to cover what you are interested in. (Please subscribe if you can!)**"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "https://www.youtube.com/watch?v=NxBBBPjusyA"
   ]
  }
 ],
 "metadata": {
  "anaconda-cloud": {},
  "kernelspec": {
   "display_name": "Python [conda env:py36]",
   "language": "python",
   "name": "conda-env-py36-py"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.1"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 1
}
